{/* LAYOUT模板 */}
	<layout name="layout"/>
{/* LAYOUT模板 */}
{/* import Js,Css */}
	<js href="__PUBLIC__/js/admin/listTable.js"/>
	<js href="__PUBLIC__/js/admin/js.util.js"/>
	<css href="__PUBLIC__/css/admin/common.css"/>
	<js href="__PUBLIC__/js/admin/js.selectzone.js"/>
	
	<css href="__PUBLIC__/css/jquery-ui.css" />
	<js href="__PUBLIC__/js/core/jquery-ui.1.10.4.js" />
	<js href="__PUBLIC__/js/core/plugins.js"/>
{/* import js,css */}
<!-- [position] -->
	<include file="Template:position"/>
<!-- [position] -->

<div class="main-div">
	<form method="post" action="wholesale.php" name="theForm" enctype="multipart/form-data" onSubmit="return validate()">
		<table width="100%">
			<!-- {if $form_action eq "insert"} 编辑时不能改商品名称 -->
			<tr>
				<td align="right">请先搜索商品</td>
				<td>
					<!-- 分类 -->
					<select name="cat_id">
						<option value="0">所有分类</option>
						{$cat_list}
					</select>
					<!-- 品牌 -->
					<select name="brand_id">
						<option value="0">所有品牌</option>
						{html_options options=$brand_list}
					</select>
					<!-- 关键字 -->
					商品编号、名称或货号
					<input name="keyword" type="text" id="keyword" size="10">
					<!-- 搜索 -->
					<input name="search" type="button" id="search" value="搜索"  onclick="searchGoods()" />
				</td>
			</tr>
			<!-- {/if} -->
			<tr>
				<td class="label" align="right">批发商品名称：</td>
				<td>
					<select name="goods_id" id="goods_id" onchange="document.getElementById('price-div').innerHTML = ''; getGoodsInfo(this.value);">
						<option value="0" selected="selected">请先搜索商品</option>
						<option value="{$wholesale.goods_id}" selected="selected">{$wholesale.goods_name}</option>
					</select>
					<input name="goods_name" type="hidden" id="goods_name" value="{$wholesale.goods_name}" />
				</td>
			</tr>
			<tr>
				<td class="label" align="right">适用会员等级：</td>
				<td>
					<volist name="user_rank_list" id="rank">
						<input name="rank_id[]" type="checkbox" id="rank_id[]" value="{$rank.rank_id}" <if condition="$rank['checked']">checked="checked"</if> />
						{$rank.rank_name} 
					</volist>
				</td>
			</tr>
			<tr>
				<td class="label" align="right">是否启用：</td>
				<td>
					<label>
						<input type="radio" name="enabled" value="1" <if condition="$wholesale['enabled']">checked="checked"</if> />
						是
					</label>
					<label>
						<input type="radio" name="enabled" value="0" <if condition="$wholesale['enabled'] eq 0">checked="checked"</if> />
						否
					</label>   
				</td>
			</tr>
		</table>

		<hr/>

		<div id="price-div">
			<volist name="wholesale['price_list']" id="attr_price" >
				<table width="100%">
					<!-- {if $attr_list} 该商品的属性 -->
					<tr>
						<td>&nbsp;</td>
						<td colspan="2">
						<volist name="attr_list" id="attr">
							{$attr.attr_name} 
							<select name="attr_{$attr.attr_id}[{$key}]"> 
								{html_options options=$attr.goods_attr_list selected=$attr_price.attr[$attr.attr_id]}
							</select>
						</volist>
						</td>
						<td>
							<if condition="$key eq 0">
								<input type="button"  value=" + " onclick="addAttr(this)" /> 
							<else/>
								<input type="button"  value=" - " onclick="dropAttr(this)" /> 
							</if>
						</td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td></td>
						<td colspan="3" style="border-bottom:1px #000 dashed;"></td>
						<td></td>
					</tr>
					<volist name="attr_price['qp_list']" id="qp">
					<tr>
						<td width="10%">&nbsp;</td>
						<td> 数量 <input name="quantity[{$key}][]" type="text" value="{$qp.quantity}" /> </td>
						<td> 价格 <input name="price[{$key}][]" type="text" value="{$qp.price}" /> </td>
						<td> 
							<if condition="$key eq 0">
								<input type="button"  value=" + " onclick="addQuantityPrice(this, '{$key}')" /> 
							<else/>
								<input type="button"  value=" - " onclick="dropQuantityPrice(this)" /> 
							</if>
						</td>
						<td width="10%">&nbsp;</td>
					</tr>
					</volist>
				</table>
			</volist>
		</div>

		<table width="100%">
			<tr>
				<td colspan="2" align="center">
				<input type="submit"  value="确定" />
				<input type="reset"  value="重置" />
				<input type="hidden" name="act" value="{$form_action}" />
				<input type="hidden" name="id" value="{$wholesale.act_id}" />
				<input type="hidden" name="seed" id="seed" value="{$key}" />
				</td>
			</tr>
		</table>
	</form>
</div>

